home *** CD-ROM | disk | FTP | other *** search
- unit CUnit;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- Db, ExtCtrls, DBCtrls, Grids, DBGrids, DBClient, ScktComp, StdCtrls;
-
- type
- TForm2 = class(TForm)
- ClientSocket1: TClientSocket;
- ClientDataSet1: TClientDataSet;
- DBGrid1: TDBGrid;
- DBNavigator1: TDBNavigator;
- DataSource1: TDataSource;
- Button1: TButton;
- Button2: TButton;
- procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- private
- { Private declarations }
- SocketText: String;
- public
- { Public declarations }
- end;
-
- var
- Form2: TForm2;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm2.FormActivate(Sender: TObject);
- begin
- SocketText := '';
- end;
-
- procedure TForm2.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
- var
- F: System.Text;
- begin
- Caption := Caption + '.';
- SocketText := SocketText + Socket.ReceiveText;
- if Pos('</DATAPACKET>',SocketText) > 0 then
- begin
- System.Assign(F,'client.xml');
- Rewrite(F);
- writeln(F,SocketText);
- System.Close(F);
- Caption := Caption + '!';
- SocketText := ''
- end
- end;
-
- procedure TForm2.Button1Click(Sender: TObject);
- begin
- if (Sender AS TButton).Caption = 'Connect' then
- begin
- (Sender AS TButton).Caption := 'Disconnect';
- ClientSocket1.Active := True
- end
- else
- begin
- (Sender AS TButton).Caption := 'Connect';
- ClientSocket1.Active := False
- end
- end;
-
- procedure TForm2.Button2Click(Sender: TObject);
- begin
- ClientDataSet1.LoadFromFile('client.xml');
- end;
-
- end.
-